import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { SimpleTableColumn, SimpleTableComponent } from '@delon/abc';
import { SFSchema } from '@delon/form';
import { MyModalHelper } from '@core/my-modal.helper';
import { DistrictService } from '@core/routes-services/district.service';
import { DistrictEditComponent } from '../district-edit/district-edit.component';
import { myValidNull } from '@core/util/string-utils';
import { MarketSalesmanRoleChangeService } from '@core/routes-services/market-salesman-role-change.service';
import { NzMessageService } from 'ng-zorro-antd';
import { MARKET_SALESMAN_ROLE } from '../../../constant/dictionary';

@Component({
  selector: 'app-role-change-record',
  templateUrl: './role-change-record.component.html',
})
export class RoleChangeRecordComponent implements OnInit {

  isLoading = false;
  keyword: any;
  page: any = { number: 1, size: 10, totalElements: 0, content: [] };

  marketSalesmanRole: any[] = MARKET_SALESMAN_ROLE;

  constructor(private message: NzMessageService,
              private marketSalesmanRoleChangeService: MarketSalesmanRoleChangeService,
              private modalHelper: MyModalHelper) {
  }

  ngOnInit() {
    this.initPage();
  }


  initPage() {
    this.isLoading = true;
    this.marketSalesmanRoleChangeService.pagination(this.page, this.keyword).then((res) => {
      if (res.status.toString().startsWith('20')) {
        this.page = res.data;
        ++this.page.number;
      } else {
        this.message.warning(res.message);
      }
      this.isLoading = false;
    }, error => {
      this.message.error(error.message ? error.message : error.error);
      this.isLoading = false;
    });
  }

  /**
   * 搜索重置分页数据
   */
  search() {
    this.page = { number: 0, size: 10, totalElements: 0, content: [] };
    this.initPage();
  }

  changePageNo(pageNo) {
    this.page = { number: pageNo, size: 10, totalElements: 0, content: [] };
    this.initPage();
  }


}
